#include <stdio.h>

#include <stdlib.h>


int main()
{
    int sum  = 0;
    int n = 0;
    
    int sum_array[10000] = {0};
    while(1)
    {
         int i = 1;
         sum = 0;
         printf("请输入n值：\n");
         if(!scanf("%d", &n))
         {
             break;
         }
        if(sum_array[n] == 0)
        {
            for(; i<=n; i++)
            {
                sum += i;
            }
            sum_array[n] = sum;
        }

         printf("sum=%d\n",sum_array[n]);
    }
}
